package com.xing.lei.happy.controller;

import com.xing.lei.happy.logic.ExcelToolsLogic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

@RestController
public class ExcelToolsController {

    @Autowired
    private ExcelToolsLogic excelToolsLogic;
    
    @RequestMapping(value = "/api/v1/excel/export", method = RequestMethod.GET)
    public void export(HttpServletResponse response, @RequestParam("tableName") String tableName) {
        try {
            excelToolsLogic.export(response, tableName);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}